//冒泡排序
;(() => {
  const fn = (arr: Array<number>) => {
    for (let i = 0; i < arr.length - 1; i++) {
      for (let j = 0; j < arr.length - i - 1; j++) {
        if (arr[j] > arr[j + 1]) {
          const tep = arr[j]
          arr[j] = arr[j + 1]
          arr[j + 1] = tep
        }
      }
    }
    return arr
  }
  console.log(fn([3, 2, 1, 5, 6, 7]))
  //find 查找数组中第一个质数
  const fn1 = (arr: any) => {
    let start: number = 2
    while (start <= Math.sqrt(arr)) {
      if (arr % start++ < 1) {
        return false
      }
    }
    return arr
  }
  console.log(fn1([3, 4, 6, 8, 9, 12].find(Array)))
  //时间戳
  let date: any = new Date()
  const Y = date.getFullYear() + '-'
  const M = date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1 + '-'
  const D = date.getDate()
  console.log(Y + M + D)
})()
